package com.xinzhi.controller;

import com.xinzhi.pojo.User;
import com.xinzhi.service.IUserService;
import com.xinzhi.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserService userService;
//    @Options("/")
//    @Delete("/")
//    @PutMapping("/")
//    @GetMapping("/")
//    @PostMapping("/")

    @PostMapping("/register")
    public Result register(@RequestBody User user){
     return userService.register(user);
    }
    @PostMapping ("/login")
    public Result login(@RequestBody User user){
        return userService.login(user);
    }
    @RequestMapping("/getUser")
    public String getUser(){
        return userService.getUser();
    }
    @RequestMapping("/updateUser")
    public Result updatePwd(@RequestBody User user){
        return userService.updateUser(user);
    }
    @RequestMapping("/deleteUser")
    public Result deleteUser(){
        return userService.deleteUser();
    }
    @RequestMapping("/secondLogin")
    public Result secondLogin(@RequestHeader("Authorization")String token){
        return userService.secondLogin(token);
    }

}
